package com.ifnk.portaljava.dapWeb.socket;

import com.ifnk.portaljava.dapWeb.dapweb.LinkedListQueue;
import com.ifnk.portaljava.hlyt.test.CdrPktInfo;

import java.util.*;
import java.util.concurrent.ConcurrentLinkedQueue;

/**
 * @author HLYT
 * 
 */
public class ClientProperty {
	
	public Map<String, CdrPktInfo> cdrPktInfoMap = new HashMap<String, CdrPktInfo>();
	//public ThreadPoolExecutor tpe = new ThreadPoolExecutor(1, 10, 5000, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(1000), new ThreadPoolExecutor.DiscardOldestPolicy());
	private String clientId;
	// rawquery请求返回的pkt，存放cdr的key与pkt的sequenceNo的集合
	private Map<String, List<Integer>> cdrPackets = new HashMap<String, List<Integer>>();
	private boolean keepLive = true;
	private long keepLiveTime;
	private int receiveCdrCount = 0;
	private int receivePktCount = 0;
	private int receivePktNoRepeat = 0;
	private PacketProcess pp = null;
	private String requestDateFromProxyId;
	private boolean timeout;
	
	
	public boolean isTimeout() {
		return timeout;
	}

	public void setTimeout(boolean timeout) {
		this.timeout = timeout;
	}

	// 存放 cdr pkt命令历史记录,用于时间排序
	private CommandHistory ch;
	
	public CommandHistory getCh() {
		return ch;
	}

	public void setCh(CommandHistory ch) {
		this.ch = ch;
	}

	// 存放接收到的proxy的数据的集合
	public LinkedListQueue<byte[]> packets = new LinkedListQueue<byte[]>();
	// 存放向页面发送的cdr的集合
	public LinkedListQueue<Object> data = new LinkedListQueue<Object>();
	// 标识页面是否点击stop
	private boolean stoped = false;
	
	// 标识页面是否点击clear
	private boolean pktStoped = false;
	// 向页面发送数据线程的集合
	public List<SendDataToFlex> sendThreads = new ArrayList<SendDataToFlex>();
	public List<SendDataToFlex> getSendThreads() {
		return sendThreads;
	}

	public void setSendThreads(List<SendDataToFlex> sendThreads) {
		this.sendThreads = sendThreads;
	}
	
	public synchronized boolean add(SendDataToFlex obj) {
		return this.sendThreads.add(obj);
	}
	
	// 处理rawData数据线程集合
	public List<ProcessRawData> doRawDataThreads = new ArrayList<ProcessRawData>();
	

	public List<ProcessRawData> getDoRawDataThreads() {
		return doRawDataThreads;
	}

	public void setDoRawDataThreads(List<ProcessRawData> doRawDataThreads) {
		this.doRawDataThreads = doRawDataThreads;
	}
	
	public synchronized boolean addProcessRawData(ProcessRawData obj) {
		return this.doRawDataThreads.add(obj);
	}

	// 处理数据线程的集合
	public List<PacketProcess> process = new ArrayList<PacketProcess>();
	// 存放rawData数据的集合
	private Queue<byte[]> rawDataPackets = new ConcurrentLinkedQueue<byte[]>();
	// 处理RawData数据的线程
	public ProcessRawData processRawData = null;
	private Map<Integer, String> cdrMap = new HashMap<Integer, String>();
	private String cdrKey;
	
	

	public String getClientId() {
		return clientId;
	}

	public void setClientId(String clientId) {
		this.clientId = clientId;
	}

	public Map<String, List<Integer>> getCdrPackets() {
		return cdrPackets;
	}

	public void setCdrPackets(Map<String, List<Integer>> cdrPackets) {
		this.cdrPackets = cdrPackets;
	}

	public boolean isKeepLive() {
		return keepLive;
	}

	public void setKeepLive(boolean keepLive) {
		this.keepLive = keepLive;
	}

	public synchronized long getKeepLiveTime() {
		return keepLiveTime;
	}

	public synchronized void setKeepLiveTime(long keepLiveTime) {
		this.keepLiveTime = keepLiveTime;
	}

	public synchronized int getReceiveCdrCount() {
		//loger.debug("getReceiveCdrCount:="+receiveCdrCount);
		return receiveCdrCount;
	}

	public synchronized void setReceiveCdrCount(int receiveCdrCount) {
		//loger.debug("setReceiveCdrCount:="+receiveCdrCount);
		this.receiveCdrCount = receiveCdrCount;
	}

	public synchronized int getReceivePktCount() {
		return receivePktCount;
	}

	public synchronized void setReceivePktCount(int receivePktCount) {
		this.receivePktCount = receivePktCount;
	}

	public int getReceivePktNoRepeat() {
		return receivePktNoRepeat;
	}

	public void setReceivePktNoRepeat(int receivePktNoRepeat) {
		this.receivePktNoRepeat = receivePktNoRepeat;
	}

	public PacketProcess getPp() {
		return pp;
	}

	public void setPp(PacketProcess pp) {
		this.pp = pp;
	}

	public LinkedListQueue<byte[]> getPackets() {
		return packets;
	}

	public void setPackets(LinkedListQueue<byte[]> packets) {
		this.packets = packets;
	}

	public Map<Integer, String> getCdrMapt() {
		return cdrMap;
	}

	public void setCdrMap(Map<Integer, String> cdrMap) {
		this.cdrMap = cdrMap;
	}

	public String getCdrKey() {
		return cdrKey;
	}

	public void setCdrKey(String cdrKey) {
		this.cdrKey = cdrKey;
	}



	public boolean isStoped() {
		return stoped;
	}

	public void setStoped(boolean stoped) {
		this.stoped = stoped;
	}

	public Queue<byte[]> getRawDataPackets() {
		return rawDataPackets;
	}

	public void setRawDataPackets(Queue<byte[]> rawDataPackets) {
		this.rawDataPackets = rawDataPackets;
	}

	public String getRequestDateFromProxyId() {
		return requestDateFromProxyId;
	}

	public void setRequestDateFromProxyId(String requestDateFromProxyId) {
		this.requestDateFromProxyId = requestDateFromProxyId;
	}

	public synchronized LinkedListQueue<Object> getData() {
		return data;
	}

	public synchronized void setData(LinkedListQueue<Object> data) {
		this.data = data;
	}

	public void setPktStoped(boolean pktStoped) {
		this.pktStoped = pktStoped;
	}

	public boolean isPktStoped() {
		return pktStoped;
	}


}
